package com.ict.web.controller.yzq;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ict.web.domain.CloudResourceRequirement;
import com.ict.web.dto.InsertCloudResourceDto;
import com.ict.web.dto.UpdateCloudResourceDto;
import com.ict.web.service.ICloudResourceRequirementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ict.common.annotation.Log;
import com.ict.common.core.controller.BaseController;
import com.ict.common.core.domain.AjaxResult;
import com.ict.common.enums.BusinessType;
import com.ict.common.core.page.TableDataInfo;

/**
 * 云资源需求Controller
 * 
 * @author ruoyi
 * @date 2022-03-07
 */
@Api(tags = "云资源需求")
@RestController
@RequestMapping("/system/requirement")
public class CloudResourceRequirementController extends BaseController
{
    @Autowired
    private ICloudResourceRequirementService cloudResourceRequirementService;

    /**
     * 查询云资源需求列表
     */
    @ApiOperation("查询云资源列表")
    @GetMapping("/list")
    public TableDataInfo list()
    {
        startPage();
        List<CloudResourceRequirement> list =cloudResourceRequirementService.selectCloudResourceRequirementList();
        return getDataTable(list);
    }

    /**
     * 获取云资源需求详细信息
     */
    @ApiOperation("获取云资源详情")
    @GetMapping(value = "/{cloudResourceId}")
    public AjaxResult getInfo(@PathVariable("cloudResourceId") Long cloudResourceId)
    {
        return AjaxResult.success(cloudResourceRequirementService.selectCloudResourceRequirementByCloudResourceId(cloudResourceId));
    }

    /**
     * 新增云资源需求
     */
    @ApiOperation("新增云资源")
    @Log(title = "云资源需求", businessType = BusinessType.INSERT)
    @PostMapping("/addSave")
    public AjaxResult add(Long programmeId, @RequestBody InsertCloudResourceDto addDto)
    {
        return toAjax(cloudResourceRequirementService.insertCloudResourceRequirement(programmeId,addDto));
    }

    /**
     * 修改云资源需求
     * @param updateDto
     * @return
     */
    @ApiOperation("修改云资源")
    @Log(title = "云资源需求", businessType = BusinessType.UPDATE)
    @PutMapping("/editSave")
    public AjaxResult edit(@RequestBody UpdateCloudResourceDto updateDto){
        return toAjax(cloudResourceRequirementService.updateCloudResourceRequirement(updateDto));
    }

    /**
     * 删除云资源需求
     */
    @ApiOperation("删除云资源")
    @Log(title = "云资源需求", businessType = BusinessType.DELETE)
	@DeleteMapping("/{cloudResourceId}")
    public AjaxResult remove(@PathVariable Long cloudResourceId)
    {
        return toAjax(cloudResourceRequirementService.deleteCloudResourceRequirementById(cloudResourceId));
    }
}
